package com.example.myapplication

import kotlinx.coroutines.*

fun main() {

    val launch = GlobalScope.launch {
        println("开始 ")
        val token = requestToken()
        val post = createPost(token, "item")
        val postResult = processPost(post)
        println("结束 ")
        this.cancel()
    }

    CoroutineScope(Dispatchers.Default).launch {

    }

    launch.cancel()
    Thread.sleep(60*60*1000L) // 阻塞主线程来保证 JVM 存活

}

suspend fun requestToken():String{
    println("获取token")
    return  "token"
}

suspend fun createPost(token:String,item:String):String{
    println("创建postItem")
    return  "$token + $item"
}

suspend fun processPost(post:String):String{
    println("执行post请求")
    return  "$post + result"
}
